package util

import (
	"fmt"
	"gpt-api/framework/cache"
	"strconv"
)

func GetDaySymbolRedisKey(marketPair string) string {
	return fmt.Sprintf("pair_%s_symbol_quote", marketPair)
}

func GetCoinSymbolMapKey() string {
	return "symbol_map_coin"
}

func GetCoinPricePerformanceKey(marketPair string) string {
	return fmt.Sprintf("pair_%s_symbol_price_performance", marketPair)
}

func GetNewsLangRedisKey(newsId uint64) string {
	return fmt.Sprintf("news_%d_lang_type", newsId)
}

func GetNewsVisitRedisKey(lang string) string {
	lang = NewsLang(lang)
	return fmt.Sprintf("lang_%s_news_visit_key", lang)
}

func GetNewsRealVisitRedisKey(lang string) string {
	lang = NewsLang(lang)
	return fmt.Sprintf("lang_%s_news_real_visit_key", lang)
}

func NewsLatestDayRealVisit(lang string, days int) string {
	lang = NewsLang(lang)
	return fmt.Sprintf("lang_%s_news_latest_%d_day_real_visit", lang, days)
}

func GetNewsVisitCount(redisCli *cache.RedisClient, lang string, newsId uint64) int {
	lang = NewsLang(lang)
	visitKey := GetNewsVisitRedisKey(lang)
	count := redisCli.ZScore(visitKey, strconv.FormatUint(newsId, 10)).Val()
	return int(count)
}

// ObjectSupportRedisKey 对象赞数量缓存
func ObjectSupportRedisKey(objectType int8) string {
	return fmt.Sprintf("support_of_object_%d", objectType)
}

// ObjectCommentCountRedisKey 对象评论数量缓存
func ObjectCommentCountRedisKey(objectType int8) string {
	return fmt.Sprintf("comment_of_object_%d", objectType)
}

// ObjectParentCommentReplyCountRedisKey 对象评论数量缓存
func ObjectParentCommentReplyCountRedisKey(objectType int8) string {
	return fmt.Sprintf("object_%d_parent_commen_reply_count", objectType)
}

func ChannelVerifyKey(channel, account, scene string) string {
	return fmt.Sprintf("STR:USRE:VERIFY:%s:%s:%s", scene, channel, account)
}

func GetCoinDayVolume(marketPair string, days int) string {
	return fmt.Sprintf("pair_%s_symbol_%d_volume_summary", marketPair, days)
}
